<template>
	<view>
        <view class="uni-list">
            <block v-for="(item,index) in res" :key="index">
                <view class="uni-list-cell" hover-class="uni-list-cell-hover">
                    <view class="uni-triplex-row">
                        <view class="uni-triplex-left">
                            <text class="uni-title uni-ellipsis" style="font-size: 28upx;padding: 0;" v-cloak> v-cloakitem.title}}{{item.money}}</text>
                            <text class="uni-text" style="font-size: 24upx;" v-cloak>{{item.createtime}} {{item.remark}}</text>
                        </view>
                        <view class="uni-triplex-right">
                            <view class="status" v-if="item.status == 1" style="background: #04ab02;">充值成功</view>
                            <view class="status" v-else-if="item.status == -1" style="background: #ab6902;">充值失败</view>
                            <view class="status" v-else-if="item.status == 3" style="background: #a6a6a6;">退款</view>
                            <view class="status" v-else-if="item.status == 6" style="background: #ffa039;">充值中</view>
                        </view>
                    </view>
                </view>
            </block>
        </view>
		<view v-if="res.length == 0" style="padding-top: 300upx;">
			<image src="../../static/searchlist.png" mode="" style="display: block;margin: 0 auto;width: 240upx;height: 240upx;"></image>
			<view style="text-align: center;color: #999;">暂时没有任何记录</view>
		</view>
		<uni-load-more v-if="load == 1" :loadingType="loadingType" :contentText="contentText"></uni-load-more>
	</view>
</template>

<script>
	import uniLoadMore from '../../components/uni-load-more.vue'
	export default {
		components: {uniLoadMore},
		data() {
			return {
				res:[],
				cointitle:' ',
				index:2,
				loadingType:0,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多了"
				},
				systemInfo: {},
				load: 0,
				openid:''
			};
		},
		onLoad:function(e){
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					if(e != ''){
						this.cointitle = '&cointitle='+ e.cointitle
					}
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		methods:{
			setAjax(){
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.log.get_list&app=1&page=1'+this.cointitle,
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						if(res.data.result.total > res.data.result.pagesize){
							this.load = 1
						}
						this.res = res.data.result.list
						uni.hideLoading()
						uni.stopPullDownRefresh();
					},
					fail: () => {},
					complete: () => {}
				});
			}
		},
		onPullDownRefresh() {
			this.setAjax();
		},
		onReachBottom(){
			if (this.loadingType !== 0) {
				return;
			}
			this.loadingType = 1;
			uni.request({
				url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.log.get_list&app=1&page='+this.index,
				method: 'POST',
				data: {'openid':this.openid},
				header:{'Content-Type':'application/x-www-form-urlencoded'},
				success: res => {
					if(res.data.result.list.length == 0){
						this.loadingType = 2;
						return;
					}
					this.res = this.res.concat(res.data.result.list)
					this.loadingType = 0;
					this.index = this.index + 1;
				},
				fail: () => {},
				complete: () => {}
			});
			
		},
	}
</script>

<style>.status{width:100%;font-size:24upx;background:#e0e0e0;text-align:center;color:#fff;margin-top:21upx;}</style>